/*
 * tab_search.h
 *
 *  Created on: 12.06.2013
 *      Author: SpirTanol
 */

#ifndef TAB_SEARCH_H_
#define TAB_SEARCH_H_

// QT
#include <QWidget>
#include <QVector>

class QComboBox;
class QPushButton;
class QProgressBar;

class MainWindow;
class SearchDialog;

class TableDevice;
class DeviceInfo;

class SearchThread;
class SearchEvent;

class TabSearch : public QWidget
{
	Q_OBJECT

	TableDevice *oDeviceTable;

	QComboBox *oComboPort;
	QComboBox *oComboSpeed;

	QPushButton *oBtnSearch;
	QPushButton *oBtnStop;
	QPushButton *oBtnAdd;
	QPushButton *oBtnConnect;
	QPushButton *oBtnDisconnect;

	QProgressBar *oProgressBar;

	QVector<DeviceInfo*> oDevices;
	SearchThread *oThread;

	int oPortIndex;
	int oSpeedIndex;

	MainWindow *oMainWindow;
	SearchDialog *oSearchDialog;

public:
	TabSearch(MainWindow *mainWindow, QWidget *parent = 0);
	~TabSearch();

	void onConnected();
	void onDisconnected();

private:
	SearchThread *searchThread();
	void saveFindResults();
	void loadFindResults();

private slots:
	/** Вызывается в случае изменения скорости или порта */
	void onSetupChanged();
	void onBtnSearchClicked();
	void onBtnStopClicked();
	void onBtnAddClicked();
	void onBtnConnectClicked();
	void onBtnDisconnectClicked();
	void onSearchEvent(SearchEvent *e);
	void onSelectDevice(DeviceInfo *dev);

};

#endif /* TAB_SEARCH_H_ */
